<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
{{--<link rel="stylesheet" href="/static/css/login.css">--}}
<div class="row login_main">
    <div class="col-md-3 col-sm-3 col-12 ">
        <div class="login-page">
            <div class="auth-brand text-center text-lg-left">
{{--                /uploads/{!! config('settings.logo') !!}--}}
                <img src="/img/apple.png" width="35"> &nbsp;Apple{!! config('settings.crmname') !!}
            </div>

            <div class="login-box">
                <div class="login-logo mb-2">
                    <h4 class="mt-0">Sign In</h4>
                    <p class="login-box-msg mt-1 mb-1">{{ __('admin.welcome_back') }}</p>
                </div>
                <div class="card">
                    <div class="card-body login-card-body">

                        <form id="login-form" method="POST" action="{{ admin_url('auth/login') }}">

                            <input type="hidden" name="_token_" value="{{ csrf_token() }}"/>

                            <fieldset class="form-label-group form-group position-relative has-icon-left">
                                <input
                                    type="text"
                                    id="username"
                                    class="form-control {{ $errors->has('username') ? 'is-invalid' : '' }}"
                                    name="username"
                                    placeholder="{{ trans('admin.username') }}"
                                    value=""
                                    required
                                    autofocus
                                >

                                <div class="form-control-position">
                                    <i class="feather icon-user"></i>
                                </div>

                                <label for="email">{{ trans('admin.username') }}</label>

                                <div class="help-block with-errors"></div>
                                @if($errors->has('username'))
                                    <span class="invalid-feedback text-danger" role="alert">
                                                    @foreach($errors->get('username') as $message)
                                            <span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
                                        @endforeach
                                                </span>
                                @endif
                            </fieldset>

                            <fieldset class="form-label-group form-group position-relative has-icon-left">
                                <input
                                    minlength="5"
                                    maxlength="20"
                                    id="password"
                                    type="password"
                                    class="form-control {{ $errors->has('password') ? 'is-invalid' : '' }}"
                                    name="password"
                                    value=""
                                    placeholder="{{ trans('admin.password') }}"
                                    required
                                    autocomplete="current-password"
                                >

                                <div class="form-control-position">
                                    <i class="feather icon-lock"></i>
                                </div>
                                <label for="password">{{ trans('admin.password') }}</label>

                                <div class="help-block with-errors"></div>
                                @if($errors->has('password'))
                                    <span class="invalid-feedback text-danger" role="alert">
                                                    @foreach($errors->get('password') as $message)
                                            <span class="control-label" for="inputError"><i class="feather icon-x-circle"></i> {{$message}}</span><br>
                                        @endforeach
                                                    </span>
                                @endif
                            </fieldset>
                            <div class="form-group d-flex justify-content-between align-items-center">
                                <div class="text-left">
                                    @if(config('admin.auth.remember'))
                                        <fieldset class="checkbox">
                                            <div class="vs-checkbox-con vs-checkbox-primary">
                                                <input id="remember" name="remember"  value="1" type="checkbox" {{ old('remember') ? 'checked' : '' }}>
                                                <span class="vs-checkbox">
                                                                <span class="vs-checkbox--check">
                                                                  <i class="vs-icon feather icon-check"></i>
                                                                </span>
                                                            </span>
                                                <span> {{ trans('admin.remember_me') }}</span>
                                            </div>
                                        </fieldset>
                                    @endif
                                </div>
                            </div>
                            <a href="/plugins/qq/example/oauth/index.php"><img src="/img/qq.png" alt="" width="30px" height="30px" class="one" ></a>
                            <a href="" rel="external" class="register"><span>注册账号</span></a>
                            <button type="submit" class="btn btn-primary float-right login-btn" id="login-cyj">
                                {{ __('admin.login') }}
                                &nbsp;
                                <i class="feather icon-arrow-right"></i>
                            </button>
                            <br>
                        </form>

                    </div>
                </div>

            </div>

            <div class="qrcode_main" style="margin-top: 50px">
                <button type="button" id="cyj">登录</button>
                <p class="qr">扫码获取用户名密码</p>
                <img class="qrcode" src="" alt="">
                <p class="id"></p>
            </div>
        </div>
    </div>
    <div class="col-md-9 col-sm-9 col-12 auth-fluid-right">
        <div class="auth-user-testimonial">
            <h2 class="mb-3">Stay Hungry, Stay Foolish!</h2>
            <p class="lead"><i class="mdi mdi-format-quote-open"></i>你如果出色地完成了某件事，那你应该再做一些其他的精彩事儿。不要在前一件事上徘徊太久，想想接下来该做什么... <i class="mdi mdi-format-quote-close"></i>
            </p>
            <p>
                - 乔布斯
            </p>
        </div> <!-- end auth-user-testimonial-->
    </div>
</div>
<form action="{{ admin_url('auth/login') }}" method="POST" id="form">
    <input type="hidden" name="username" class="username" value="">
    <input type="hidden" name="password" class="password" value="">
    <input type="hidden" name="_token" class="_token" value="{{ csrf_token() }}"/>
    <input type="button" id="cyjq" value="123">
</form>
</body>
</html>
<script>
    function login(){
        var username = $(".username").val()
        var password = $(".password").val()
        var _token = $("._token").val()
        $.ajax({
            url:"{{admin_url('auth/login')}}",
            type:'POST',
            data:{username,password,_token},
            dataType:'json',
            success:function (result) {
                console.log(result)
                window.location.href=''
            }
        })
    }
    $("#cyjq").click(function () {
        login()
    })
    Dcat.ready(function () {
        // ajax表单提交
        $('#login-form').form({
            validate: true,
        });
    });
    $('.register').click(function () {
        window.location.href="/register"
    })
    $(".qr").click(function () {
        $.ajax({
            url:"http://www.cyjyyds.cn/api/qr",
            dataType:'json',
            success:function (result) {
                $(".qrcode").attr('src',result.url)
                $(".id").text(result.id)
                var wsServer = 'ws://49.234.48.38:2346';
                var websocket = new WebSocket(wsServer);
                websocket.onopen = function (evt) {
                    var eventKey = $(".id").text()
                    var message = {
                        type:'bind',
                        data:{'eventKey':eventKey}
                    }
                    let jsonMessage = JSON.stringify(message)
                    websocket.send(jsonMessage)
                };

                websocket.onclose = function (evt) {
                    console.log("Disconnected");
                };

                websocket.onmessage = function (evt) {
                    //获取场景值
                    var eventKey = $(".id").text()
                   // console.log(eventKey)
                    //服务端传回来的消息
                    var message = JSON.parse(evt.data)
                    var openId = message.data.open_id;
                    var websocketEventKey = message.data.eventKey;
                    //入如果服务端传过来的场景值和生成二维码时的场景值一直则请求用户信息
                    if (websocketEventKey==eventKey){
                        $.ajax({
                            url:'/index.php/api/qr_post',
                            type:'POST',
                            data:{
                                open_id:openId
                            },
                            dataType: 'json',
                            success:function (result) {
                                console.log(result)
                                if(result.code==200){
                                    $(".username").val(result.data.username)
                                    $(".password").val(result.data.password)
                                    login()
                                }
                            }
                        })
                    }else{
                        alert('请刷新页面')
                    }
                };

                websocket.onerror = function (evt, e) {
                    console.log('Error occured: ' + evt.data);
                };

            }
        })
    })














</script>
<style>
    page{
        background-color: #ffffff;
        position: fixed;
    }
    .col-md-12,
    .col-md-3 {
        padding: 0;
    }

    .row {
        margin: 0;
    }

    .login_main {
        position: relative;
        display: flex;
        /*align-items: center;*/
        min-height: 100vh;
        flex-direction: row;
        align-items: stretch;
        background: url(/img/psc19.jpg) center;
        background-size: cover;
        margin: 0;
    }
    .login-page {
        background-color: #fff;
    }
    .card {
        box-shadow: 0 0px;
    }
    .auth-brand {
        position: absolute;
        top: 3rem;
        left: 6rem;
        font-size: 26px;
    }
    .login-logo {
        font-size: 2.1rem;
        font-weight: 300;
        margin-bottom: 0.9rem;
        text-align: left;
        margin-left: 20px;
    }
    .btn {
        width: 100%;
    }


    body.dark-mode .login_main {
        background: url(/img/qq.png) center;
        background-size: cover;
    }

    .login_main .login-box-msg,
    .login_main .register-box-msg {
        margin: 0;
        padding: 0 0px 20px;
        color: #98a6ad !important;
        font-size: 0.9rem;
        font-weight: 400;
        text-align: left;
    }


    .auth-fluid-right {
        padding: 6rem 3rem;
        flex: 1;
        position: relative;
        color: #fff;
        background-color: rgba(0, 0, 0, 0.3);
        text-align: center !important;
        font-family: Nunito, sans-serif;
    }

    .auth-user-testimonial {
        position: absolute;
        margin: 0 auto;
        padding: 0 1.75rem;
        bottom: 3rem;
        left: 0;
        right: 0;
    }

    .auth-user-testimonial .mb-3 {
        color: #fff;
        font-weight: 700;
        margin: 10px 0;
        font-size: 5rem;
    }
     .one{
        margin-left: 300px;
         margin-top: -80px;
    }
    .qrcode_main {
        text-align: center;
        position: absolute;
        bottom: 100px;

    }
    .qrcode {
        width: 100px;

    }
</style>
